
#ifndef GOMOKU_CORE_STATE_H__
# define GOMOKU_CORE_STATE_H__

# include <gomoku/core/Gomoku.h>
# include <gomoku/core/StateStack.h>

# include <gomoku/core/IGui.h>
# include <gomoku/core/IPlayer.h>
# include <gomoku/core/IReferee.h>

namespace gomoku
{

    struct Context
    {
        Context();
        Context(IGui *gui_, IPlayer *black_, IPlayer *white_, IReferee *referee_);
        Context(Context const & t);
        Context &operator=(Context const & t);

        IGui *gui;
        IPlayer *black;
        IPlayer *white;
        IReferee *referee;
    };

    class State
    {
    public:
        State(StateStack &stack, Context context)
            : _stack(&stack), _context(context)
        {}

        virtual ~State()
        {}

        virtual bool handleEvent(void) = 0;
        virtual bool update(float) = 0;
        virtual void draw(void) = 0;

    protected:
        void requestPush(StateID stateID);
        void requestPop();
        void requestClear();

        Context getContext() const;
    protected:
        StateStack *_stack;
        Context _context;
    };
}

#endif  // GOMOKU_CORE_STATE_H__
